<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 学生成绩表
        var scores = [
            { id: 1, chinese: 105, math: 62, english: 118 },
            { id: 2, chinese: 89, math: 78, english: 120 },
            { id: 3, chinese: 86, math: 64, english: 80 },
            { id: 4, chinese: 78, math: 99, english: 91 },
            { id: 5, chinese: 107.5, math: 97, english: 70 },
            { id: 6, chinese: 112, math: 61, english: 92 },
            { id: 7, chinese: 101, math: 79, english: 104 },
            { id: 8, chinese: 71, math: 72, english: 105 },
            { id: 9, chinese: 56, math: 68, english: 61 },
            { id: 10, chinese: 98, math: 83, english: 77 }
        ];

        // 计算总成绩并添加到对象中
        scores.forEach(function(student) {
            student.total = student.chinese + student.math + student.english;
        });

        // 按总成绩排名
        scores.sort(function(a, b) {
            return b.total - a.total;
        });

        console.log("按总成绩排名：");
        console.table(scores);

        // 统计各单科成绩第一名
        var highestChinese = scores.reduce((max, student) => max.chinese > student.chinese ? max : student);
        var highestMath = scores.reduce((max, student) => max.math > student.math ? max : student);
        var highestEnglish = scores.reduce((max, student) => max.english > student.english ? max : student);

        console.log("各单科成绩第一名：");
        console.log("语文：", highestChinese);
        console.log("数学：", highestMath);
        console.log("英语：", highestEnglish);
    </script>
</body>
</html>
